﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace TiledPlatformer.Entity
{
    public enum ObjectType
    {
        SOLID,
        PASSTHRU,
    }
    public class GameObject
    {
        public Rectangle collisionBox;
        public Vector2 position;

        public ObjectType type;

        protected Texture2D texture;

        public bool Expired;

        public GameObject(Vector2 position, int width, int height)
        {
            this.position = position;
            collisionBox = new Rectangle((int)position.X, (int)position.Y, width, height);
            Expired = false;
        }

        public GameObject(Vector2 position, Texture2D texture)
        {
            this.position = position;
            this.texture = texture;
            collisionBox = new Rectangle((int)position.X, (int)position.Y, texture.Width, texture.Height);
            Expired = false;
        }

        public virtual void OnCollide(GameObject o) { }

        public virtual void Draw(SpriteBatch batch)
        {
            if (texture != null)
                batch.Draw(texture, collisionBox, Color.White);
            else
            {
                Texture2D defaultTexture = new Texture2D(Platformer.graphics.GraphicsDevice, 1, 1, true, SurfaceFormat.Color);
                defaultTexture.SetData(new[] { Color.White });
                texture = defaultTexture;
                batch.Draw(texture, collisionBox, Color.White);
            }
        }
    }
}
